/**
 * @project readnote
 * @Title LoginInfoAutoSetInterceptor.java
 * @deprecated 登录信息LoginInfo自动加载到AppBaseAction拦截器
 * @author huxh
 * @date 2012-2-20
 **/
package com.cr.backbone.intercepter;

import com.cr.backbone.action.AppBaseAction;
import com.cr.backbone.action.LoginInfo;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class UserLoginInfoAutoSetInterceptor implements Interceptor {

	private static final long serialVersionUID = -8379316954832555503L;

	public void destroy() {
	}

	public void init() {
	}

	/**
	 * 登录信息自动加载拦截器
	 */
	public String intercept(ActionInvocation invocation) throws Exception {
		
		if(invocation.getAction() instanceof  AppBaseAction){
			LoginInfo loginInfo = (LoginInfo)ActionContext.getContext().getSession().get(SessionInterceptKeys.LOGIN_USER_LOGIN_INFO_KEY);
			
			if(loginInfo !=null )
				((AppBaseAction)(invocation.getAction())).setLoginInfo(loginInfo);
		}
		
		//不论自动加载结果，执行action
		return invocation.invoke();
	}

}
